﻿using CodeCity.SDK;
using CodeCity.UserManagement.Service.ApplicationModel;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace CodeCity.UserManagement.Admin.Controllers
{
    [ApiController]
    [Route("api/[controller]")]
    public class UserController : ControllerBase
    {
        private readonly GameConnection gameConnection;

        public UserController(GameConnection gameConnection)
        {
            this.gameConnection = gameConnection;
        }

        [HttpPost("login")]
        public async Task<string> LoginAsync([FromBody] LoginRequestModel loginRequestModel)
        {
            await gameConnection.ConnectAsync(loginRequestModel.Username, loginRequestModel.Password);
            return GameConnection.AccessToken;
        }
    }
}
